# ----------------io密集型------------------------
import time,threading
def ListenMusic(name):
    print("beging listening to %s,%s" %(name,time.ctime()))
    time.sleep(5)
    print("end listening %s" % time.ctime())

def Recordlog(name):
    print("beging recoding to %s,%s" %(name,time.ctime()))
    time.sleep(5)
    print("end recoding %s" % time.ctime())
if __name__ == '__main__':
    threads=[]
    t1=threading.Thread(target=ListenMusic,args=("凤凰传奇",))
    t2=threading.Thread(target=Recordlog,args=("python多线程",))
    threads.append(t1)
    threads.append(t2)
    for t in threads:
        t.start()


# --------------计算密集型---------------------

import threading,time
def add():
    s=0
    for i in range(100000990):
        s +=i
    print("累加的结果是：",s)
def mul():
    s1=1
    for i in range(1,10000):
        s1 *= i
    print("累乘的结果是：",s1)

if __name__ == '__main__':
    start= time.time()
    L = []
    t1=threading.Thread(target=add)
    t2=threading.Thread(target=mul)

    L.append(t1)
    L.append(t2)
    for t in L:
        t.start()

    for t in L:
        t.join()

    print("总共花费时间",time.time()-start)